<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./../template/WorkspaceTemplate.xhtml">

    <ui:define name="top">

    </ui:define>

    <ui:define name="left">

    </ui:define>

    <ui:define name="right">

    </ui:define>

    <ui:define name="content">

        <h2>View Purchase Plan</h2>
        <h:form id="createPurchasePlanForm" style="font-size: 85%">
            <p:panel >
                <p:messages />
                <br/>
                <br/>
                <br/>
                <h:outputText value="Purchase Planning Details" style="font-weight: bold; font-size: 110%"/>
                <p:separator/>
                <br/>
                <h:panelGrid columns="2" cellpadding="10">
                    <h:outputLabel style="font-weight: bold" value="Planning Period Start Date (Monday of every week): " />
                    <h:outputText value="#{prManagerBean.purchasePlan.datePurchasePlan}">
                        <f:convertDateTime pattern="MMMM dd, yyyy"/>
                    </h:outputText>
                    <h:outputLabel style="font-weight: bold" value="Currency: " />
                    <h:outputText value="#{prManagerBean.purchasePlan.currency?'SGD':'USD'}" />
                    <h:outputLabel style="font-weight: bold" value="Urgent: " />
                    <h:outputText value="#{prManagerBean.purchasePlan.urgent?'Yes':'No'}" />
                </h:panelGrid>
                <br/>
                <br/>
                <br/>
                <h:panelGroup id="purchasePlanForm"  style="padding: 0px" rendered="#{prManagerBean.purchasePlan != null}">
                    <h:outputText value="Purchase Orders" style="font-weight: bold; font-size: 110%"/>
                    <p:separator/>
                    <br/>
                    <p:dataTable var="po" rowIndexVar="rowIndex" value="#{prManagerBean.purchasePlan.rmpos}">

                        <p:column headerText="No." >  
                            <h:outputText value="#{rowIndex + 1}" />  
                        </p:column>

                        <p:column headerText="Supplier" >  
                            <h:outputText value="#{po.supplier.supplierName}" />  
                        </p:column>

                        <p:column headerText="Invoice No." >  
                            <h:outputText value="#{po.poNum}" />  
                        </p:column>

                        <p:column headerText="Total (SGD)" rendered="#{prManagerBean.purchasePlan.currency}" >  
                            <h:outputText value="#{po.totalSGD}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>  
                        </p:column>

                        <p:column headerText="Total (USD)" rendered="#{!prManagerBean.purchasePlan.currency}">  
                            <h:outputText value="#{po.totalUSD}">
                                <f:convertNumber type="currency"/>
                            </h:outputText>  
                        </p:column>

                        <p:column headerText="View PO">  
                            <p:commandButton image="ui-icon ui-icon-search" title="View PO" actionListener="#{prManagerBean.viewPurchaseOrderDisplayPO}" action="viewPurchasePlanDisplayPO?faces-redirect=true" >
                                <f:attribute name="selected" value="#{po}"/>
                            </p:commandButton> 
                        </p:column>

                    </p:dataTable>
                    <br/>
                </h:panelGroup>
                <br/>
            </p:panel>

            <br/>
            <br/>

        </h:form>


    </ui:define>

    <ui:define name="bottom">

    </ui:define>

</ui:composition>
